from day01.basecla import BaseClass
from day01.basecla import driver
from selenium.webdriver.common.by import By
from time import sleep
c=BaseClass()
c.open_browser('http://sahitest.com/demo/alertTest.htm')
locator={
    "click_alert1":"//input[@name='b1']",
    "click_alert2":"//input[@name='b2']",
    "unicode":"//input[@name='b3']"
}
mytext=c.location(By.XPATH,'//input[1]')
alert1=c.location(By.XPATH,locator['click_alert1'])
alert2=c.location(By.XPATH,locator['click_alert2'])
myunicode=c.location(By.XPATH,locator['unicode'])
sleep(2)
mytext.clear()
mytext.send_keys("请输入姓名")
sleep(2)
alert1.click()
sleep(2)
alerttext=driver.switch_to.alert
print('获得弹出框的文字:',alerttext.text)
alerttext.accept()
c.close_browser()

